package org.springframework.zp.batis.util;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.zp.batis.mybatis.MySqlSession;

/**
 * 1、MyFactoryBean自己必须生效 存在spring容器当中
 * 2、mapperInterface必须有值（合理）
 */
//@Component
public class MyFactoryBean implements FactoryBean {

	Class mapperInterface;

	public void setMapperInterface(Class mapperInterface) {
		this.mapperInterface = mapperInterface;
	}

	@Override
	public Object getObject() throws Exception {
		// 模拟 Mybatis 对接口产生代理对象的过程
		Object mapper = MySqlSession.getMapper(mapperInterface);
		return mapper;
	}

	@Override
	public Class<?> getObjectType() {
		return mapperInterface;
	}


}
